{% extends 'layout.html' %}

{% block title %}{{title}}{% endblock %}

{% block style %}
<link rel="stylesheet" href="/dest/css/editor.min.css" type="text/css">
{% endblock%}
{% block secondtitle %}{{secondtitle}}{% endblock %}

{% block content %}
<div class="wrapper-md">

    <div id="docs-wrap" class="row">

        <form id="docs-form" class="form-horizontal" action="/preview?type=doc" method="post" target="_blank">
            <div class="col-sm-9">
                <div class="panel panel-default">
                    <div class="panel-body" style="padding: 50px 40px 50px 60px;">


                        <!--标题-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">标题</label>

                            <div class="col-sm-10">
                                <input type="text" name="title" v-model="docs.title" v-validate="minLength:10" class="form-control"
                                       autofocus placeholder="title:标题字数 10 字以上" value="{{docs.title}}">
                            </div>
                        </div>

                        <div class="line line-dashed b-b line-lg pull-in"></div>

                        <!--标签-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">标签</label>

                            <div class="col-sm-10">
                                <input type="text" name="tags" v-model="docs.tags" class="form-control"
                                       placeholder="tag:多个标签请用英文逗号（,）分开" value="{{docs.tags}}">
                            </div>
                        </div>

                        <div class="line line-dashed b-b line-lg pull-in"></div>

                        <!--连接-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">github/link</label>

                            <div class="col-sm-10">
                                <input type="text" name="github" v-model="docs.github" class="form-control" placeholder="link:请输入相关网址" value="{{docs.projectLink}}">
                            </div>
                        </div>

                        <div class="line line-dashed b-b line-lg pull-in"></div>


                        <!--分类-->
                        <!--<div class="form-group">-->
                            <!--<label class="col-sm-2 control-label">分类目录</label>-->

                            <!--<div class="col-sm-10">-->
                                <!--<select v-model="docs.category" name="category" class="form-control">-->
                                    <!--{% for category in categories%}-->
                                    <!--<option value="{{category.name}}" {% if docs.category == category.name || loop.first %}selected{% endif %}>{{category.name}}</option>-->
                                    <!--{% endfor %}-->
                                <!--</select>-->
                            <!--</div>-->
                        <!--</div>-->
                        <!--<div class="line line-dashed b-b line-lg pull-in"></div>-->

                        <!--简介-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">介绍</label>

                            <div class="col-sm-10">
                                <textarea v-model="docs.description" name="description" class="form-control" rows="3" placeholder="description:文档相关介绍">{{docs.description}}</textarea>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>


                        <div class="form-group">
                            <label class="col-sm-2 control-label">封面</label>

                            <div class="col-sm-10">
                                <input type="file" id="docs-cover"
                                       style="position: absolute; clip: rect(0px 0px 0px 0px);">

                                <div class="bootstrap-filestyle input-group">
                                    <input id="docs-uri" type="text" class="form-control"
                                           placeholder="cover:图片尺寸200X200" disabled>
                                    <span class="group-span-filestyle input-group-btn" tabindex="0">
                                        <label for="docs-cover" class="btn btn-default">
                                            <span class="glyphicon glyphicon-folder-open"></span>
                                            &nbsp;&nbsp;封面上传
                                        </label>
                                    </span>
                                </div>
                            </div>
                        </div>


                        <div class="line line-dashed b-b line-lg pull-in"></div>

                        <!--文档内容-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label" style="padding-top: 15px;">文档内容</label>

                            <div class="col-sm-10">
                                <textarea id="editor" name="content" placeholder="Content here ....">{{docs.content}}</textarea>
                            </div>
                        </div>
                        <input type="hidden" v-model="docs.edit" value="{{edit}}"/>
                        <!-- end editor -->


                    </div>
                </div>
            </div>
            {% if edit %}
                <script>
                    var istop = {{docs.istop}}, isgood = {{docs.isgood}}, iscomment = {{docs.iscomment}}, cstatus = {{docs.status}}, recommend = {{docs.recommend}};
                </script>
            {% else %}
                <script>
                    var istop = false, isgood = false, iscomment = true, cstatus = true, recommend = false;
                </script>
            {%endif%}

            <div class="col-sm-3">
                <div class="panel b-a">
                    <div class="panel-heading b-b">发布处理</div>
                    <div class="panel-body">
                        {% if user.role > 1 %}
                        <div class="checkbox">
                            <label class="i-checks">
                                <input type="checkbox" value="" v-model="docs.istop" />
                                <i></i>
                                对文档置顶操作
                            </label>
                        </div>
                        <div class="checkbox">
                            <label class="i-checks">
                                <input type="checkbox" value="" v-model="docs.isgood" />
                                <i></i>
                                添加为精华
                            </label>
                        </div>
                        <div class="checkbox">
                            <label class="i-checks">
                                <input type="checkbox" value="" v-model="docs.recommend" />
                                <i></i>
                                加入推荐
                            </label>
                        </div>
                        {% endif %}
                        <div class="checkbox">
                            <label class="i-checks">
                                <input type="checkbox" value="" v-model="docs.iscomment" >
                                <i></i>
                                是否支持评论功能
                            </label>
                        </div>
                        <div class="radio">
                            <label class="i-checks">
                                <input type="radio" name="status" value="1" v-model="docs.cstatus" />
                                <i></i>
                                发布
                            </label>
                        </div>
                        <div class="radio">
                            <label class="i-checks">
                                <input type="radio" name="status" value="0"  v-model="docs.cstatus" />
                                <i></i>
                                草稿
                            </label>
                        </div>
                    </div>
                    <div class="b-t panel-body">
                        <button type="submit" class="btn btn-default">预览</button>
                        <button type="submit" class="btn btn-primary pull-right" v-attr="disabled:!valid" v-on="click:submit">
                            保存
                        </button>
                    </div>

                </div>
            </div>

        </form>
    </div>

</div>
{% endblock %}

{% block loadjs %}
<script type="text/javascript">
    require(['docs/doc.min']);
</script>
{% endblock %}